<%@ page language="java" contentType="text/javascript; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import='java.sql.*' %>
<%@page import="java.util.ArrayList"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONSerializer"%>
<%@page import="net.sf.json.JSONArray"%>

<%String callback = request.getParameter("callback");%>
<%=callback %> (<%

	String id = request.getParameter("id");

	Connection conn = null;
	PreparedStatement pstmt = null;
	
	try{
		Class.forName("com.mysql.jdbc.Driver");
		conn = DriverManager.getConnection(
			"jdbc:mysql://localhost/itscreater", "itscreater", "campus123");
	
		String select = "select * from UserInfo where ID= ?;";
		pstmt = conn.prepareStatement(select);
		pstmt.setString(1, id);
		ResultSet rs = pstmt.executeQuery();
		
		JSONObject jo = new JSONObject();
		//JSONArray ja = new JSONArray();
		if (rs.next()) {
			String getid = rs.getString("ID");
			String getname = rs.getString("Name");
			String getemail = rs.getString("Email");
			String getage = rs.getString("Age");
			String getgender = rs.getString("Gender");
			String getintroduction = rs.getString("Introduction");
			if (getintroduction != null) {
				getintroduction = getintroduction.replace("\n","<br>");
				getintroduction = getintroduction.replace("\u0020","&nbsp;");
			}
			String getcacao = rs.getString("Cacao");
			String getlat = rs.getString("UserLat");
			String getlng = rs.getString("UserLng");
			String gettheme = rs.getString("UserTheme");
			
			jo.put("ID", getid);
			jo.put("Name", getname);
			jo.put("Email", getemail);
			jo.put("Age", getage);
			jo.put("Gender", getgender);
			jo.put("Introduction", getintroduction);
			jo.put("Cacao", getcacao);
			jo.put("UserLat", getlat);
			jo.put("UserLng", getlng);
			jo.put("UserTheme", gettheme);
			
			jo.put("success", "true");
			
			//ja.add(jo);
		} 		
	
		//out.print(ja);
		out.print(jo);	
	}
	
	finally{
		try{
			pstmt.close();
		}
		catch (Exception ignored){
		}
		try{
			conn.close();
		}
		catch (Exception ignored){
		}
	}
%>);